﻿//using System.Collections;
//using System.Collections.Generic;
//using UnityEngine;
///// <summary>
///// Screen main.
///// </summary>
//using HLLib;
//using WorldDefine;

/////

//public class ScreenMain : MonoBehaviour, IHLWorldListener
//{

//    /// <summary>
//    /// The m screen main.
//    /// </summary>
//    public static ScreenMain m_screenMain = null;
//	public int curGameState = 0;


//	/// <summary>
//	/// The m hlworldmain.
//	/// </summary>
//	public HLWorldMain m_hlworldmain = null;
//	public HLWorld m_hlworld = null;


//	/// <summary>
//	/// The temp vec3.
//	/// </summary>
//	private Vector3 _tempVec3 = Vector3.zero;
//	private GameObject _tempGameObject = null;
//	private GameObject _obj_camera_target_top = null;



//	/// <summary>
//	/// Awake this instance.
//	/// </summary>
//	void Awake()
//	{
//		Application.targetFrameRate = -1;
//		m_screenMain = this;
//		///
//	}


//	/// <summary>
//	/// Start this instance.
//	/// </summary>
//	void Start () 
//	{
//		m_hlworldmain = new HLWorldMain ();
//		m_hlworld = m_hlworldmain.m_hlWorld;
//		m_hlworld.setHLWorldListener(this); // rem destroy IHLWorldListener
//		_tempGameObject = new GameObject();
//		_tempGameObject.name = "_tempGameObject";
//		curGameState = GameStateType.GAME_INIT;
//		this.initGame();
//	}


//	/// <summary>
//	/// Inits the game.
//	/// </summary>
//	void initGame()
//	{
//		switch(curGameState)
//		{
//			case GameStateType.GAME_INIT:
//			{
//				this.StopCoroutine("createGameInfo");
//				this.StartCoroutine("createGameInfo");
//				break;
//			}
//			case GameStateType.GAME_RUN:
//			{
				
//				break;
//			}
//		}
//	}


//	/// <summary>
//	/// Creates the game info.
//	/// </summary>
//	/// <returns>The game info.</returns>
//	IEnumerator createGameInfo()
//	{
//		yield return new WaitForEndOfFrame();
//		// create ui:
//		createUI();
//		// create player:
//		_tempGameObject.transform.position = new Vector3( -4.59f, 0.0f, -11.27f);
//		_tempGameObject.transform.rotation = Quaternion.Euler(Vector3.zero);
//		_tempGameObject.transform.localScale =  new Vector3( 1.5f, 1.5f, 1.5f);
//		createPlayer("1001_qingtan_prefab",  _tempGameObject.transform, PLAYER_ACTION_STAND);

//		// create mainCamera:
//		createMainCamera();

//		// create sounds:
//		changeBackSounds();

//		// create game data:
//		createGameData();

//		// start game:
//		curGameState = GameStateType.GAME_RUN;
//		Debug.Log("start game");
//	}
		
		
//	/// <summary>
//	/// Createbattles the U.
//	/// </summary>
//	public void createUI()
//	{
		
//	}


//	#region -------------------- logic camera --------------------
//	public const int TARGET_FIELD_OF_FOV = 50;
//	public Vector3 _vec3_target_camera;
//	public Camera main_camera = null;
//	/// <summary>
//	/// Creates the main camera.
//	/// </summary>
//	public void createMainCamera()
//	{
////		_vec3_target_camera = new Vector3( 0.0f, 28.6f, -11.9f); // 0.0f, 14.72, -6.8f //  0.0f, 38.0f, -25.0f
////		_camera_target_top
//		Transform []_transArray = _hlgameobj_player.transform.GetComponentsInChildren<Transform>();
//		for(int i = _transArray.Length; --i>=0; )
//		{
////			Debug.Log(_transArray[i].name);
//			if(_transArray[i].name.Equals("camera_target_top"))
//			{
//				_obj_camera_target_top = _transArray[i].gameObject;
//				Debug.Log("_obj_camera_target_top: " + _obj_camera_target_top.name);
//			}
//		}
////		Debug.Log("-----------------------------------------");
//		for(int i = Camera.allCameras.Length; --i >= 0; )
//		{	
//			if(Camera.allCameras[i].name.Equals("Main Camera"))
//			{
//				main_camera = Camera.allCameras[i];
//			}
//		}
//	}


//	/// <summary>
//	/// Logics the camera.
//	/// </summary>
//	public void logicCamera()
//	{
//		if( null != _obj_camera_target_top)
//		{
////			Debug.Log("_vec3_target_camera: " + _vec3_target_camera);
//			/// position:
//			_tempVec3.x = _hlgameobj_player.transform.position.x + _vec3_target_camera.x;
//			_tempVec3.y = _hlgameobj_player.transform.position.y + _vec3_target_camera.y;
//			_tempVec3.z = _hlgameobj_player.transform.position.z + _vec3_target_camera.z;
//			_tempVec3 = Vector3.Lerp(main_camera.transform.position, _tempVec3, 2.0f * Time.deltaTime);
//			main_camera.transform.position = _tempVec3;
//			///

//			/// fov: 
//			main_camera.fieldOfView = Mathf.Lerp(main_camera.fieldOfView , TARGET_FIELD_OF_FOV, 2.0f * Time.deltaTime);
//		}

////		if(Camera.main == null)
////		{
////			Debug.Log("NULL!!!!");
////		}
//	}

//	#endregion


//	/// <summary>
//	/// Changes the back sounds.
//	/// </summary>
//	public void changeBackSounds()
//	{
		
//	}


//	/// <summary>
//	/// Creates the game data.
//	/// </summary>
//	public void createGameData()
//	{
		
//	}


//	/// <summary>
//	/// Update this instance.
//	/// </summary>
//	void Update () {
//		switch(curGameState)
//		{
//			case GameStateType.GAME_RUN:
//			{
//				// player gourp:
//				logicPlayerGroup();

//				// player bullet gourp:
//				logicPlayerBulletGroup();

//				break;
//			}
//		}
//	}


//	/// <summary>
//	/// Lates the update.
//	/// </summary>
//	void LateUpdate()
//	{
//		// camera:
//		logicCamera();
//	}


//	#region ------------------ player logic group --------------------
//	public HLGameObject _hlgameobj_player = null;
//	public Vector3 vec3_controlmove = Vector3.zero;


//	public int //
//		//
//	PLAYER_ACTION_STAND = 0,
//	PLAYER_ACTION_WALK = 1,
//	PLAYER_ACTION_ATTCK = 2,
//	PLAYER_ACTION_BEATEN = 3,
//	PLAYER_ACTION_DEAD = 4;

//	public float //
//		//
//	PLAYER_TANKE_MOVE_SPEED_XZ = 5.0f;


//	/// <summary>
//	/// The player action array.
//	/// </summary>
//	public string []player_action_array = new string[]
//	{
//		"PLAYER_ACTION_STAND",
//		"PLAYER_ACTION_WALK",
//		"PLAYER_ACTION_ATTCK",
//		"PLAYER_ACTION_BEATEN",
//		"PLAYER_ACTION_DEAD"
//	};


//	/// <summary>
//	/// Creates the player.
//	/// </summary>
//	/// <returns>The player.</returns>
//	private HLGameObject createPlayer(string _prefab_name, Transform _trans, int _action_type)
//	{
//		HLGameObject _hlgameobj = null;
//		/// ab:
//		/// resources:
//		_hlgameobj = new HLGameObject (HLWorldDefine.PATH_MODELS, _prefab_name); 
//		_hlgameobj_player = _hlgameobj;
//		_hlgameobj.extVec3 = Vector3.zero;
//		_hlgameobj.gameobject.layer = LayerMask.NameToLayer("Layer_Player");
//		if( null != _trans )
//		{
//			_hlgameobj.gameobject.transform.position = _trans.position;
//			_hlgameobj.gameobject.transform.rotation = _trans.rotation;
//			_hlgameobj.gameobject.transform.localScale = _trans.localScale;
//		}
//		else 
//		{
//			_tempVec3 = Vector3.zero;
//			_hlgameobj.gameobject.transform.position = _tempVec3;
//		}
//		_hlgameobj.setAnimation(player_action_array[_action_type], _action_type);
//		m_hlworld.addGameObjectWithGroupArray(m_hlworld.getGroupByPlayer(), _hlgameobj);
//		return _hlgameobj;
//	}


//	/// <summary>
//	/// Gets the name of the object trans from point.
//	/// </summary>
//	/// <returns>The object trans from point name.</returns>
//	private Transform getObjTransFromPointName(GameObject _obj, string _point_name)
//	{
//		foreach(Transform _trans in _obj.transform)
//		{
//			if(_trans.name.Equals(_point_name))
//				return _trans;
//		}
//		return null;
//	}


//	/// <summary>
//	/// Logics the player.
//	/// </summary>
//	/// <param name="_hlgameobj">Hlgameobj.</param>
//	/// <param name="i">The index.</param>
//	private void logicPlayer( HLGameObject _hlgameobj, int i)
//	{
		
//		if(_hlgameobj.curAnimate == PLAYER_ACTION_STAND)
//		{
			
//		}
//		else if(_hlgameobj.curAnimate == PLAYER_ACTION_WALK)
//		{

//		}
//		else if(_hlgameobj.curAnimate == PLAYER_ACTION_ATTCK)
//		{
//			if(_hlgameobj.curFrame >= _hlgameobj.getFrameLength() - 3)
//				_hlgameobj.setAnimation(player_action_array[PLAYER_ACTION_STAND], PLAYER_ACTION_STAND);
//			///
////			Debug.Log("_hlgameobj.curEventTimer: " + _hlgameobj.curEventTimer);
//			if(_hlgameobj.isFrameNum(10))
//			{
//				Transform _trans_point = getObjTransFromPointName(_hlgameobj.gameobject,"point_fire");
//				createPlayerBullet(HLWorldDefine.PATH_MODELS, "bullet_prefab", _trans_point);
//			}
//		}
//		else if(_hlgameobj.curAnimate == PLAYER_ACTION_BEATEN)
//		{

//		}
//		else if(_hlgameobj.curAnimate == PLAYER_ACTION_DEAD)
//		{

//		}
//		///
//		_hlgameobj_player.characterController.Move(vec3_controlmove);
//	}


//	/// <summary>
//	/// Logics the player group.
//	/// </summary>
//	private void logicPlayerGroup()
//	{
//		for(int i = m_hlworld.getGroupByPlayer().Count; --i >= 0;)
//			logicPlayer(m_hlworld.getGroupByPlayer()[i], i);
//	}


//	/// <summary>
//	/// Lefts the joy stick start.
//	/// </summary>
//	public void leftJoyStickStart()
//	{
		
//	}


//	/// <summary>
//	/// Lefts the joy stick move.
//	/// </summary>
//	public void leftJoyStickMove(Vector2 _vec2_joystick)
//	{
//		if( null == _hlgameobj_player )
//			return;
//		/// position && rotation:
//		vec3_controlmove.x = _vec2_joystick.x * PLAYER_TANKE_MOVE_SPEED_XZ * Time.deltaTime;
//		vec3_controlmove.y = 0.0f;
//		vec3_controlmove.z = _vec2_joystick.y * PLAYER_TANKE_MOVE_SPEED_XZ * Time.deltaTime;
//		///
//		_tempVec3 = _hlgameobj_player.transform.position;
//		_tempVec3.x = _tempVec3.x + _vec2_joystick.x;
//		_tempVec3.y = _tempVec3.y;
//		_tempVec3.z = _tempVec3.z + _vec2_joystick.y;
//		_hlgameobj_player.transform.LookAt(_tempVec3);
		
//	}	


//	/// <summary>
//	/// Calculas the angle.
//	/// </summary>
//	/// <returns>The angle.</returns>
//	/// <param name="_joyPositionX">Joy position x.</param>
//	/// <param name="_joyPositionY">Joy position y.</param>
//	private float CalculaAngle (float _joyPositionX, float _joyPositionY)
//	{
//		float currentAngleX = _joyPositionX * 90f + 90f;//X轴 当前角度
//		float currentAngleY = _joyPositionY * 90f + 90f;//Y轴 当前角度

//		//下半圆
//		if (currentAngleY < 90f) {
//			if (currentAngleX < 90f) {
//				return 270f + currentAngleY;
//			} else if (currentAngleX > 90f) {
//				return 180f + (90f - currentAngleY);
//			}
//		}
//		return currentAngleX;
//	}


//	/// <summary>
//	/// Lefts the joy stick end.
//	/// </summary>
//	public void leftJoyStickEnd()
//	{
//		vec3_controlmove = Vector3.zero;
//	}


//	/// <summary>
//	/// Buttons the fire.
//	/// </summary>
//	public void button_fire()
//	{
//		if(_hlgameobj_player.curAnimate == PLAYER_ACTION_STAND || _hlgameobj_player.curAnimate == PLAYER_ACTION_WALK)
//		{
//			_hlgameobj_player.setAnimation(player_action_array[PLAYER_ACTION_ATTCK], PLAYER_ACTION_ATTCK);
////			_hlgameobj_player.setPlayEventTimer(9);
//		}
			

//		//
//	}

//	#endregion


//	#region ------------------ playerbullet logic group --------------------
//	/// <summary>
//	/// Creates the player bullet.
//	/// </summary>
//	/// <returns>The player bullet.</returns>
//	/// <param name="_prefab_name">Prefab name.</param>
//	/// <param name="_trans">Trans.</param>
//	/// <param name="_action_type">Action type.</param>
//	/// <param name="isModle">If set to <c>true</c> is modle.</param>
//	private HLGameObject createPlayerBullet(string _path, string _prefab_name, Transform _trans)
//	{
//		return createPlayerBullet(_path, _prefab_name, _trans, 0,false, 200);
//	}


//	/// <summary>
//	/// Creates the player.
//	/// </summary>
//	/// <returns>The player.</returns>
//	/// <param name="_prefab_name">Prefab name.</param>
//	/// <param name="_trans">Trans.</param>
//	/// <param name="_action_type">Action type.</param>
//	private HLGameObject createPlayerBullet(string _path, string _prefab_name, Transform _trans, int _action_type, bool isModle, int _timers)
//	{
//		HLGameObject _hlgameobj = null;
//		/// ab:
//		/// resources:
//		_hlgameobj = new HLGameObject (_path, _prefab_name); 
//		_hlgameobj.extVec3 = Vector3.zero;
//		_hlgameobj.gameobject.layer = LayerMask.NameToLayer("Layer_PlayerBullet");
//		_hlgameobj.timer = _timers;
//		if( null != _trans )
//		{
//			_hlgameobj.gameobject.transform.position = _trans.position;
//			_hlgameobj.gameobject.transform.rotation = _trans.rotation;
////			_hlgameobj.gameobject.transform.localScale = _trans.localScale;
//		}
//		else 
//		{
//			_tempVec3 = Vector3.zero;
//			_hlgameobj.gameobject.transform.position = _tempVec3;
//		}
//		///
//		if(isModle)
//		{
////			_hlgameobj.setAnimation(player_action_array[_action_type], _action_type);	
//		}
//		m_hlworld.addGameObjectWithGroupArray(m_hlworld.getGroupByPlayerBullet(), _hlgameobj);
//		return _hlgameobj;
//	}


//	/// <summary>
//	/// Logics the player bullet.
//	/// </summary>
//	/// <param name="_hlgameobj">Hlgameobj.</param>
//	/// <param name="i">The index.</param>
//	private void logicPlayerBullet(HLGameObject _hlgameobj, int i )
//	{
//		if( --_hlgameobj.timer < 0)
//		{
//			m_hlworld.removeGameObjectInGourpArray(m_hlworld.getGroupByPlayerBullet(), _hlgameobj);
//		}
//		else
//		{
//			_hlgameobj.gameobject.transform.Translate(Vector3.forward * 35.0f * Time.deltaTime);
//		}
//	}


//	/// <summary>
//	/// Logics the player bullet group.
//	/// </summary>
//	private void logicPlayerBulletGroup()
//	{
//		for(int i = m_hlworld.getGroupByPlayerBullet().Count; --i >= 0;)
//			logicPlayerBullet(m_hlworld.getGroupByPlayerBullet()[i], i);
//	}
//	#endregion


//	#region -------------------- reciveOnTriggerEnter -------------------
//	public void reciveOnTriggerEnter(HLGameObject _hlgameobj, GameObject colliderObj)
//	{
////		Debug.Log("_hlgameobj.name: " + _hlgameobj.gameobject.name + " ,colliderObj.name: " + colliderObj.name);
////		Debug.Log(LayerMask.LayerToName(_hlgameobj.gameobject.layer));
//		string _att_hlobj = LayerMask.LayerToName(_hlgameobj.gameobject.layer);
//		if(_att_hlobj.Equals("Layer_PlayerBullet"))
//		{
//			m_hlworld.removeGameObjectInGourpArray(m_hlworld.getGroupByPlayerBullet(), _hlgameobj);
//			_hlgameobj = null;
//		}

//		string _behit_obj = LayerMask.LayerToName(colliderObj.layer);
//		if(_behit_obj.Equals("Layer_MapObj"))
//		{
//			GameObject.Destroy(colliderObj);
//			colliderObj = null;
//		}


//	}
//	#endregion
//}
